package com.yzy.fly.entity.role;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yzy.fly.kernel.model.FlyBasicModel;
import com.yzy.fly.util.DateUtil;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

@Data
@TableName(value = "fly_enum_item", autoResultMap = true)
public class FlyEnumItem extends FlyBasicModel<Integer,FlyEnumItem> implements Serializable{

    @TableId(type = IdType.AUTO)
    private Integer id;
    private String label;
    private String name;
    @TableField(value = "`key`")
    private String key;
    @Deprecated
    private String packageName;
    @Deprecated
    private String className;
    @TableField(value = "datas",typeHandler = FastjsonTypeHandler.class)
    private JSONObject datas = new JSONObject(0);
//    @ParentId
    private Integer parentId;
    private Integer enumId;
    private Integer systemId;
    private String descr;

    @DateTimeFormat(pattern= DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss)
    @JsonFormat( pattern = DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss )
    private Date createTime;
    @DateTimeFormat(pattern= DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss)
    @JsonFormat( pattern = DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss )
    private Date updateTime;

    public String getLabel(){
//        new FlyBasicService().findFlyBasicServiceByField(this,"");
        return name;
    }
}
